package com.tsd.jxc.pub.service.impl;

import java.util.List;
import java.util.Map;
import java.util.Date;
import javax.annotation.Resource;

import com.tsd.core.utils.HlpUtils;
import com.tsd.core.vo.PageBean;
import com.tsd.jxc.pub.service.JxcDetailAttrService;
import com.tsd.jxc.pub.entity.JxcDetailAttr;
import com.tsd.jxc.pub.entity.JxcDetailAttrExt;
import com.tsd.system.entity.SysUser;
import com.tsd.jxc.pub.dao.JxcDetailAttrMapper;
import org.springframework.stereotype.Service;
import com.tsd.service.BaseServiceImpl;

/**
 * 描述：JxcDetailAttr 服务实现层
 *
 * @author david
 * @date 2024/05/07 17:02:29
 */
@Service
public class JxcDetailAttrServiceImpl extends BaseServiceImpl implements JxcDetailAttrService {

    @Resource
    private JxcDetailAttrMapper jxcDetailAttrMapper;

    @Override
    public JxcDetailAttr getJxcDetailAttrById(Long id)throws Exception {
        return jxcDetailAttrMapper.selectByPrimaryKey(id);
    }

    @Override
    public JxcDetailAttrExt queryBySid(String sid) throws Exception {
    return jxcDetailAttrMapper.selectBySid(sid);
    }

    @Override
    public void deleteJxcDetailAttrs(List<String> list, SysUser opUser)throws Exception {
        for (String sid:list){
            JxcDetailAttr old = jxcDetailAttrMapper.selectBySid(sid);
            super.checkEmpty(old,"该记录不存在");
            super.autoInjectBaseData(old,opUser,TYPE_DELETE);
            jxcDetailAttrMapper.updateByPrimaryKeySelective(old);
        }
    }

    @Override
    public void saveJxcDetailAttr(JxcDetailAttr record, SysUser opUser) throws Exception {
    	if (HlpUtils.isEmpty(record.getId())) {
            super.autoInjectBaseData(record,opUser,TYPE_CREATE);
    		jxcDetailAttrMapper.insertSelective(record);
    	} else {
            super.autoInjectBaseData(record,opUser,TYPE_UPDATE);
    		jxcDetailAttrMapper.updateByPrimaryKeySelective(record);
    	}
    }

    @Override
    public List<JxcDetailAttrExt> findJxcDetailAttrs(Map<String, Object> params, PageBean page) throws Exception {
    	return jxcDetailAttrMapper.selectByPage(params, page);
    }

    @Override
    public List<JxcDetailAttrExt> findJxcDetailAttrs(Map<String, Object> params) throws Exception {
        return jxcDetailAttrMapper.selectByParams(params);
    }
}
